package com.chenqi.service.impl;

import com.chenqi.dao.PromotionMapper;
import com.chenqi.model.entity.Promotion;
import com.chenqi.service.PromotionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 推荐业务实现层
 * @program: ardaicommunity
 * @author: ChenQi
 * @create: 2021-03-2021/3/7-15-49
 */
@Slf4j
@Service
@Transactional(rollbackFor = {Exception.class})
public class PromotionServiceImpl implements PromotionService {

    @Autowired
    private PromotionMapper promotionMapper;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public List<Promotion> getAllPromotions() {
        List<Promotion> promotions = new ArrayList<>();
        try {
            promotions = promotionMapper.selectList(null);
        }catch (Exception e){
            log.error(e.getMessage());
        }
        return promotions;
    }
}
